<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function handleData(arr, bool = true) {
        // x = x || 0;
        let sum = 0;
        for (let i of arr) {
          sum += i;
        }
        // let averge = sum / arr.length;
        // if (x === true) {
        //   return sum;
        // } else if (x === 0) {
        //   return sum;
        // } else if (x === false) {
        //   return averge;
        // }
        return (bool = true ? true : false);
      }
      const re = handleData([1, 2, 3, 4, 5], true);
      console.log = re;
      const re1 = handleData([1, 2, 3, 4, 5]);
      console.log = re1;
      const re3 = handleData([1, 2, 3, 4, 5], false);
      console.log = re3;
    </script>
  </body>
</html>
